<?php
/*
 * @Author: 哲学家乔布斯 <wuyangii@qq.com>
 * @Date: 2022-11-01 22:19:42
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-11-01 22:19:54
 * @Descripttion: 
 */


namespace app\common\model;

use think\Model;

class City extends Base
{   
    public $path = 0;

    protected $insert = ['path'];
    protected $update = ['path'];
    
    
    //---------------自动完成----------------------
    protected function setPathAttr($value, $data)
    {
        if ($data['cid'] > 0) {
            $path = $this->where('id', $data['cid'])->value('path');
            if (!empty($path)) {
                $this->path = $path;
                return $path;
            } else {
                return 0;
            }
        } else {
            return 0;
        }
    }


    /**
     * @Author: 哲学家乔布斯 <wuyangii@qq.com>
     * @brief: 
     * @return 
     * @Descripttion: 商家昵称
     */ 
    public function getAgentNameAttr($value,$data){
        return empty($data['agent_id']) ? "暂无代理商" : (new \app\common\model\Agent())->where(['id' => $data['agent_id']])->value('name');
    }
}
